(function () {
    var navs = [
        {
            name: "后台设置",
            url: "",
            role: ["sys"],
            menu: [
                { name: "登录用户", url: "/sys/user" },
                { name: "平台商家", url: "/base/mch" }
            ]
        },
        {
            name: "基础设置",
            url: "",
            role: ["mch", "sub", "cntr","proxy"],
            menu: [
                { name: "配置设置", url: "/sys/dashboard", role: ["mch"] },
                { name: "登录账号", url: "/sys/user", role: ["mch"] },
                { name: "运输企业", url: "/base/company", role: ["mch", "sub"] },
                { name: "营运人", url: "/base/pheasant", role: ["mch", "cntr"] },
                { name: "车辆管理", url: "/sch/vehicle" },
                { name: "司机管理", url: "/sch/driver" },
                { name: "包车客户管理", url: "/base/charterdbusUser",role:["mch"]}
            ]
        },
        {
            name: "班次管理",
            url: "",
            role: ["mch", "sub","proxy"],
            model: ["kf"],
            menu: [
                { name: "站场管理", url: "/sch/station", model: ["kf"], role: ["mch", "proxy"] },
                { name: "线路管理", url: "/sch/line", model: ["kf"] },
                { name: "计划班次", url: "/sch/schedule", model: ["kf"] },
                { name: "实时班次", url: "/sch/plan", model: ["kf"] },
                { name: "用户需求", url: "/sch/vote", model: ["kf"], role: ["mch"] },
                { name: "募集列表", url: "/sch/collect", model: ["kf"], role: ["mch"] }
            ]
        },
        {
            name: "运维管理",
            url: "",
            role: ["mch", "sub", "cntr","proxy","proxyId"],
            model: ["kf"],
            menu: [
                { name: "评论管理", url: "/operation/comment", model: ["kf"], role: ["mch"] },
                { name: "线路招募", url: "/operation/attract", model: ["kf"], role: ["mch"] },
                { name: "线路上座率", url: "/operation/occupied", model: ["kf"], role: ["mch", "sub"] },
                { name: "订单统计", url: "/operation/orderStat", model: ["kf"] },
                { name: "售票明细", url: "/operation/orderAccount", model: ["kf"]},
                { name: "保险统计", url: "/operation/insuranceStatistics", model: ["kf"],role: ["mch"]},
                { name: "合同统计", url: "/operation/contractStat", model: ["kf"], role: ["mch"] },
                { name: "班次统计", url: "/operation/schStat", model: ["kf"], role: ["mch"] },
                { name: "站点乘客统计", url: "/operation/stationPeopleCounting", model: ["kf"], role: ["mch"] },
                { name: "上下班乘车点募集", url: "/sch/commutelinecollect", model: ["kf"], role: ["mch"] }
            ]
        },
        {
            name: "优惠管理",
            url: "",
            role: ["mch"],
            menu: [
                { name: "活动设置", url: "/coupon/firstuser", role: ["mch"] },
                { name: "秒杀优惠", url: "/coupon/seckill", role: ["mch"] },
                { name: "优惠券", url: "/coupon/coupon", role: ["mch"] }
            ]
        },
        {
            name: "订单管理",
            url: "",
            role: ["mch", "sub", "cntr", "proxy"],
            model: ["kf"],
            menu: [
                { name: "订单详情", url: "/order/list", model: ["kf"] },
                //{ name: "半价票退款", url: "/order/refund", role: ["mch"] },
                //{ name: "班次结算单", url: "/order/settlement", role: ["mch", "sub", "proxy"] },
                { name: "月结算单", url: "/order/timeSettlement", model: ["kf"], role: ["mch", "sub", "proxy"] },
                { name: "发票管理", url: "/order/invoice", model: ["kf"],role:["mch"] },
                { name: "保险管理", url: "/order/ccicins", role:["mch"] }
            ]
        },
        {
            name: "微信管理",
            url: "",
            role: ["mch", "sub"],
            menu: [
                { name: "网约菜单", url: "/chat/chatMenu?appid=wx14e0d38b43374f1e", role:["mch"]},
                { name: "司机菜单", url: "/chat/chatMenu?appid=wxee4c61db2e301fae", role:["mch"]},
                { name: "网约测试菜单", url: "/chat/chatMenu?appid=wx0e36c348bf461b23", role:["mch"]},
                { name: "司机测试菜单", url: "/chat/chatMenu?appid=wx9669d5b87959a072", role:["mch"]},
                { name: "网约回复", url: "/chat/reply?appid=wx14e0d38b43374f1e"},
                { name: "网约测试回复", url: "/chat/reply?appid=wx0e36c348bf461b23"},
                { name: "地推设置", url: "/chat/sale"},
                { name: "地推绩效", url: "/chat/saleperf"},
                { name: "会员管理", url: "/vip/member", role:["mch"]},
                { name: "公告管理", url: "/sch/annunciate", role:["mch"]}
            ]
        },
        {
            name: "实验室",
            url: "",
            role: ["sys","mch"],
            menu: [
                { name: "auto-complete", url: "/demo/autoComplete", role:["sys"] },
                { name: 'date', url: '/demo/date', role:["sys"] },
                { name: '模拟检票', url: '/demo/check', role:["sys"] },
                { name: 'Clockpicker', url: '/demo/clockpicker', role:["sys"] },
                { name: 'SEAT', url: '/demo/seat', role:["sys"] },
                { name: '聊天室', url: '/demo/ws', role:["sys","mch"] }
            ]
        },
        {
            name: "盐高线",
            url: "",
            role: ["mch"],
            menu: [
                { name: "盐高线路管理", url: "/yangao/yangaoLine", role:["mch"] },
                { name: '盐高学员管理', url: '/yangao/yangaoStudent', role:["mch"] },
                { name: '盐高线路排班', url: '/yangao/yangaoWorkforce', role:["mch"] }
            ]
        },
        {
            name: "包车管理",
            url: "",
            role: ["mch"],
            new : true,
            menu: [
                { name: "订单管理", url: "/baoche/order", role:["mch"] },
                { name: '我的消息', url: '/baoche/myMsg', role:["mch"] },
                { name: '所有订单统计', url: '/baoche/orderStat', role:["mch"] },
                { name: "企业客户管理", url: "/baoche/companyClientManage",role:["mch"]},
                { name: '客户经理订单统计', url: '/baoche/orderStatManager', role:["mch"] },
                { name: '企业客户订单统计', url: '/baoche/orderStatEnt', role:["mch"] },
                { name: '发票管理', url: '/baoche/invoice', role:["mch"] },
                { name: '评论管理', url: '/baoche/comment', role:["mch"] },
                { name: '评论标签管理', url: '/baoche/commentTag', role:["mch"] },
                { name: '反馈管理', url: '/baoche/feedback', role:["mch"] },
            ]
        }
    ];
	
    //类型【1：总平台，2：商家平台，3：运输企业，4：营运人】
    var ROLE = { 1: "sys", 2: "mch", 3: "sub", 4:"cntr",5:"proxyId", proxy:"proxy" };
    var role = ROLE[App.user.type];
    if(!!App.user.pheasant && App.user.pheasant.type==2){
        role = ROLE["proxy"];
    }
    App.user.role = role;

    var model = "";
    if(/网约管理员/.test(App.user.name)){
        model = "kf";
    }
    App.user.model = model;

    var data = [];
    $.each(navs, function (i, nav) {
        if (!!model && (!nav.model || nav.model.indexOf(model) == -1)) return;
        if (!!nav.role && nav.role.indexOf(role) == -1) return;
        if(App.user.code=="songshanhu002"||App.user.code=='songshanhu001'){
            if(nav.name=='基础设置'||nav.name=='班次管理')return;
        }
        var _menu = [];
        $.each(nav.menu || [], function (j, menu) {
            if(App.user.code=="songshanhu001"||App.user.code=='songshanhu002'){
                if(menu.name=='线路上座率'){
                    _menu.push(menu);
                }
            }
            if(App.user.companyId==4){
                if(menu.name=='包车客户管理'){
                    _menu.push(menu);
                }
            }
            if (!!model && (!menu.model || menu.model.indexOf(model) == -1)) return;
            if (!!menu.role && menu.role.indexOf(role) == -1) return;

            if(/.*(wybashi.com|vchepiao.cn)/.test(window.location.host)){
                if(/wx0e36c348bf461b23|wx9669d5b87959a072/.test(menu.url)){
                    return;
                }
            }else{
                if(/wx14e0d38b43374f1e|wxee4c61db2e301fae/.test(menu.url)){
                    return;
                }
            }
            _menu.push(menu);
        });
        if (_menu.length == 0) return;

        nav.menu = _menu;
        data.push(nav);
    });
    App['menu']= data;
})(App);